<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>请绑定一个账号</title>
<meta name="keywords" content="" />
<link rel="stylesheet" type="text/css" href="/common/images/common.css"/>
<link rel="stylesheet" type="text/css" href="images/css.css"/>
<script src="{cfg:(dirpath,base)}/common.php?app=sys&app_act=web.config&app_ajax=1"></script>
<script src="/common/js/kj.js"></script>
<script src="/common/js/kj.rule.js"></script>
<script src="/common/js/kj.ajax.js"></script>
<script src="/common/js/kj.dialog.js"></script>
<style>
.me_main{margin:50px auto 0px auto;width:353px;text-align:center}
.loginbox{float:left;width:353px;border:1px #cccccc solid}
.loginbox .tit{float:left;width:280px;height:36px;background:url(images/bg_1.jpg) no-repeat;text-align:left;font-weight:bold;padding:9px 0px 0px 53px}
.loginbox .logintab{float:left;width:300px;padding:10px 0px 0px 50px}
.loginbox .logintab .tab{float:left}
.loginbox .logintab td{text-align:left;font-size:14px;height:25px;}
</style>
<style>
#id_verify{position:absolute;width:130px}
</style>
</head>
<body>
<div class="me_main">
<div class="sp_w1"></div>
<div class="loginbox">
	<div class="tit"><h3>欢迎【{$openinfo['name']}】，登录成功，正在绑定到一个新账号</h3></div>
	<div class="logintab">
		<table class="tab">
		<form name="frmReg" method="post" action="index.php?app=ajax&app_act=reg" onsubmit="return jsreg.on_reg(true);">
		<input type="hidden" name="verifycode" value="">
		<tr><td>{if(cls_config::get('rule_uname','user')=='email')}邮箱：{else if(cls_config::get('rule_uname','user')=='mobile')}手机：{else}邮  箱：{/if}</td><td><div id="id_verify" style="display:none" onmouseover="kj.show(this);"><img src="" id="id_verify_pic" onclick="this.src='{cfg:(web_url,base)}/common.php?app=sys&app_act=verifycode&app_contenttype=img&app_rnd='+Math.random();"></div><input type="text" name="uname" value="" class="pTxt1 pTxtL200" onfocus="kj.hide('#id_verify');"></td></tr>
		<tr><td>密　码：</td><td><input type="password" name="pwd1" class="pTxt1 pTxtL200"></td></tr>
		<tr><td>确认密码：</td><td><input type="password" name="pwd2" class="pTxt1 pTxtL200"></td></tr>
		{if($reg_switch==2)}
		<tr><td>邀请码：</td><td><input type="password" name="invite_code" class="pTxt1 pTxtL200"></td></tr>
		{/if}
		<tr><td></td><td><input type="submit" name="loginok" value=" 绑定 " class="pSubmit">&nbsp;&nbsp;<a href="{fun_get::url(array('app_act'=>'bind.login'))}">绑定现有账号</a>&nbsp;&nbsp;<a href="{fun_get::url(array('app_act'=>'bind.auto'))}" style="color:#ff0000">直接进入</a></td></tr>
		<input type="hidden" name="jump_fromurl" value="{$jump_fromurl}" id="id_jump_fromurl">
		</form>
		</table>
	</div>
</div>
</div>
<div id="id_verify_box_reg" style="display:none">
	<div class="me_box1" style="float:left;padding:10px;line-height:40px">
	<li style="float:left;width:90%"><img src="" id="id_verify_pic_reg"  onclick="jsreg.verify_refresh();"></li>
	<li style="float:left;width:90%"><input name="verifycode" type="text" class="pTxt1 pTxtL100" id="id_verifycode"/></li>
	<li style="float:left;width:90%"><input type="submit" name="btn_verify" value="确 定" class="btn1" id="id_btn_verify" onclick="jsreg.verify_ok();"></li>
	</div>
</div>
{if(cls_config::get('rule_uname','user')=='email')}
<div id="id_verify_email_box" style="display:none">
	<div class="me_box1" style="float:left;padding:10px;line-height:40px">
	<li style="float:left;width:90%">验证码已发送到您的邮箱，请登录邮箱获取</li>
	<li style="float:left;width:90%"><input name="emailcode" type="text" class="pTxt1 pTxtL100" id="id_emailcode"/></li>
	<li style="float:left;width:90%"><span style="float:left"><input type="submit" name="btn_verify_email" value="确 定" class="btn1" id="id_btn_verify_email" onclick="jsreg.verify_email_ok();"></span><span style="float:left;padding:5px 0px 0px 10px"><a href="javascript:kj.dialog.close('#winemailcode');jsreg.on_reg()" style="color:#888888;">重新发送</a></span></li>
	</div>
</div>
{else if(cls_config::get('rule_uname','user')=='mobile')}
<div id="id_verify_email_box" style="display:none">
	<div class="me_box1" style="float:left;padding:10px;line-height:40px">
	<li style="float:left;width:90%">请输入您手机收到的验证码&nbsp;(<span id="id_email_timer_box" style="color:#ff0000">剩余：<font id="id_email_timer"></font>秒</span>)</li>
	<li style="float:left;width:90%"><input name="emailcode" type="text" class="pTxt1 pTxtL100" id="id_emailcode"/></li>
	<li style="float:left;width:90%"><span style="float:left"><input type="submit" name="btn_verify_email" value="确 定" class="btn1" id="id_btn_verify_email" onclick="jsreg.verify_email_ok();"></span><span style="float:left;padding:5px 0px 0px 10px"><a href="javascript:kj.dialog.close('#winemailcode');jsreg.on_reg()" style="color:#888888;">重新发送</a></span></li>
	</div>
</div>
{/if}
<script>
var jsreg = new function() {
	this.timer = 90;
	this.verifycode_html = '';
	this.reg_verify = true;//"{cfg:(reg_verify,user)}";
	this.rule_uname = "{cfg:(rule_uname,user)}";
	this.on_reg = function(is_re) {
		//是否需要验证码
		if(this.reg_verify=='1') {
			this.show_verify();
		}else{
			this.on_is_verify();
		}
		if(is_re) return false;
	}
	this.on_is_verify = function() {
	  if(this.rule_uname == 'email' || this.rule_uname == 'mobile') {
		this.reg_email();
	  }else{
		this.reg();
	  }
	}
	//邮箱验证
	this.reg_email = function() {
		var key = document.frmReg.uname.value;
		var verifycode = document.frmReg.verifycode.value;
		var type = '';
		if(this.rule_uname == 'email') {
			type = 'email';
		}else if(this.rule_uname=='mobile'){
			type = 'mobile';
		}
		kj.ajax.get(kj.cfg('baseurl') + '/common.php?app=sys&app_act=verify_reg&type=' + type + '&key=' + key + '&verifycode=' + verifycode, function(data) {
			var obj_data=kj.json(data);
			if(obj_data.isnull) {
				alert("系统繁忙，请稍后再来试试");
			} else {
				if(jsreg.reg_verify) {
					kj.dialog.close("#winverifycode");
				}
				if(obj_data.code == 0) {
					jsreg.show_verify_email();
					jsreg.start_time(1);
				} else {
					if('msg' in obj_data && obj_data.msg!='') {
						alert(obj_data.msg);
					} else {
						alert("系统繁忙，请稍后再来试试");
					}
					if(obj_data.code == '11') {
						jsreg.show_verify();
					} else {
						if(jsreg.reg_verify) kj.hide('#winverifycodereg');
					}
				}
			}
		});
	}
	//显示验证码
	this.show_verify = function() {
		var obj = kj.obj('#id_verify_box_reg');
		if(obj) {
			this.verifycode_html = obj.innerHTML;
			kj.remove(obj);
		}
		kj.dialog({'html':this.verifycode_html,'id':'verifycodereg','type':'html','title':'请输入验证码','w':300,'showbtnmax':false,'showbtnhide':false});
		this.verify_refresh();
	}
	//显示邮箱验证框
	this.show_verify_email = function() {
		var obj = kj.obj('#id_verify_email_box');
		if(obj) {
			this.emailcode_html = obj.innerHTML;
			kj.remove(obj);
		}
		kj.dialog({'html':this.emailcode_html,'id':'emailcode','type':'html','title':'注册验证','w':330,'showbtnmax':false,'showbtnhide':false});
	}
	this.verify_email_ok = function() {
		var val = kj.obj("#id_emailcode").value;
		if(val == '') {
			alert("请输入验证码");
			kj.obj("#id_emailcode").focus();
			return;
		}
		document.frmReg.verifycode.value = val;
		kj.obj("#id_btn_verify_email").className = '';
		kj.obj("#id_btn_verify_email").disabled = true;
		kj.obj("#id_btn_verify_email").value="正在提交，请不要关闭..";
		this.reg();
	}
	this.verify_refresh = function() {
		kj.obj("#id_verify_pic_reg").src = kj.cfg('baseurl') + '/common.php?app=sys&app_act=verifycode&app_contenttype=img&app_rnd='+Math.random();
	}
	this.verify_ok = function() {
		var val = kj.obj("#id_verifycode").value;
		if(val == '') {
			alert("请输入验证码");
			kj.obj("#id_verifycode").focus();
			return;
		}
		document.frmReg.verifycode.value = val;
		kj.obj("#id_btn_verify").className = '';
		kj.obj("#id_btn_verify").disabled = true;
		kj.obj("#id_btn_verify").value="正在提交，请不要关闭..";
		this.on_is_verify();
	}
	this.reg = function() {
		kj.ajax.post(document.frmReg , function(data) {
			var obj_data=kj.json(data);
			if(obj_data.isnull) {
				alert("系统繁忙，请稍后再来试试");
			} else {
				if(obj_data.code == 0) {
					window.open("{fun_get::url(array('app_act'=>'bind'))}","_self");
				} else {
					if('msg' in obj_data && obj_data.msg!='') {
						alert(obj_data.msg);
					} else {
						alert("系统繁忙，请稍后再来试试");
					}
					if(this.rule_uname == 'email') {
						kj.obj("#id_btn_verify_email").className = 'btn1';
						kj.obj("#id_btn_verify_email").disabled = false;
						kj.obj("#id_btn_verify_email").value="确 定";
					}
					if(jsreg.reg_verify) {
						if(kj.obj("#id_btn_verify")) {
							kj.obj("#id_btn_verify").className = 'btn1';
							kj.obj("#id_btn_verify").disabled = false;
							kj.obj("#id_btn_verify").value="确 定";
						}
					}
					if(obj_data.code == '11') jsreg.show_verify();
				}
			}
		});
	}
	this.start_time = function(isstart) {
		var obj = kj.obj("#id_email_timer");
		if(!obj) return;
		var timer = kj.toint(obj.innerHTML);
		//if(timer <= 0) timer = this.timer;
		timer--;
		if(isstart) timer = this.timer;
		if(timer<0) {
			kj.obj("#id_email_timer_box").innerHTML = '已过期';
			kj.obj("#id_btn_verify_email").className = '';
			kj.obj("#id_btn_verify_email").disabled = true;
			kj.obj("#id_btn_verify_email").value="已过期..";

		} else {
			obj.innerHTML = timer;
			setTimeout('jsreg.start_time()' , 1000);
		}
	}
	this.showlogin = function() {
		kj.hide("#winshowreg");
		if(jsheader) jsheader.showlogin();
	}
}
</script>
</body>
</html>